<script>
    $(document).ready(function(){                
        $('#add_category').validate({
            rules : {
                categoryName : { required : true}
			},
            messages : {
                categoryName : { required : ' Please enter category name'}
            }
        }); 	
	});
</script>

<?php include './pages/stockMenu.php'; ?>
<div class = "mainContent">
	<div class = "masterData">
		<h3>Available Categories</h3>
			<?php
			include("./system/dbconnection.php");
			if($result =mysql_query("SELECT * FROM categories ")){
				if(mysql_num_rows($result)){
					echo "<table border='1' width='100%' cellspacing='0' class='masterTable'>";
					echo "<tr><th size='15'>Category Id</th><th>Category Name</th><th>Category Description</th></tr>";
					while($row = mysql_fetch_array($result)){
						echo "<tr>";
						echo "<td>" . $row['categoryId'] . "</td>";
						echo "<td>" . $row['categoryName'] . "</td>";
						echo "<td>" . $row['categoryDescription'] . "</td>";
						echo "</tr>";
					}
					echo "</table>";		
				}else{
					echo "No Data in Database";
				}
			}
			?>	
	</div>
	<div class="mainForm">
		<form name="add_category" id="forma"  action="./system/action/addCategories.php" method="POST">		
			<table  width="80%">
				<tr>
					<td colspan="2">
						<?php
							if(isset($_SESSION['error']) && $_SESSION['error'] != ""  ){ ?>
								<div class="error">
									<?php echo $_SESSION['error']; ?>
								</div>
							<?php } else if(isset($_SESSION['success']) && $_SESSION['success'] != ""){?>
								<div class="success">
									<?php echo $_SESSION['success']; ?>
								</div>
							<?php }
						?>
					</td>
				</tr>
				<tr>
					<td>Category name: <label class="mandatory">*</label></td>
					<td> <input type="text" name="categoryName" id="categoryName" class="required" ></td></tr>
				<tr>
					<td>Description: </td>
					<td><input type="text" name="categoryDescription" id="categoryDescription"></td>
				</tr>
				<tr>
					<td></td>
					<td><input type="submit" name="submit" value="submit"/></td>
				</tr>
			</table>
		</form>
	</div>
</div>
	
	